package com.leyou.gateway.fallback;

import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.Map;

@RestController
@RequestMapping("/hystrix")
public class FallbackController {

    @RequestMapping("/fallback")
    public ResponseEntity<Map<String,Object>>handleFallback(){
        Map<String,Object>result = new HashMap<>();
        result.put("code",504);
        result.put("msg","服务处理超时，请稍后重试！");
        //返回响应状态及响应体
        return ResponseEntity.status(HttpStatus.GATEWAY_TIMEOUT).body(result);
    }
}
